﻿using System;
using System.Collections.Generic;
using MyBatis.Data.Contract;
using MyBatis.Data.Model;
using MyBatis.Data.Dao;
using IBatisNet.Common;

namespace MyBatis.Data.Service
{
	public class CustomersService : ICustomersService
	{
		#region 变量

		#endregion

		#region 属性
		/// <summary>
		/// CustomersDao
		/// </summary>
		public CustomersDao CustomersDao
		{
			get;
			set;
		}
		#endregion

		#region 事件

		#endregion

		#region 构造函数
		public CustomersService()
		{
			CustomersDao = new CustomersDao();
		}
		public CustomersService(string reader,string writer)
        {
            CustomersDao = new CustomersDao(reader,writer);
        }
		#endregion

		#region 方法
		/// <summary>
		/// 获取Customers
		/// </summary>
		/// <param name="customerID">CustomerID</param>
		/// <returns>Customers</returns>
		public Customers GetCustomers(string customerID)
		{
			return CustomersDao.GetCustomers(customerID);
		}
		
		/// <summary>
		/// 获取Customers集合
		/// </summary>
		/// <param name="customersQp">Customers</param>
		/// <returns>Customers集合</returns>
		public IList<Customers> GetCustomerss(CustomersQP customersQp)
		{
			return CustomersDao.GetCustomerss(customersQp);
		}

		/// <summary>
		/// 获取指定查询条件下Customers集合的记录数
		/// </summary>
		/// <param name="customersQp">Customers</param>
		/// <returns>Customers集合</returns>
		public int GetCustomerssCount(CustomersQP customersQp)
		{
			return CustomersDao.GetCustomerssCount(customersQp);
		}
		
		/// <summary>
		/// 有否Customers
		/// </summary>
		/// <param name="customerID">CustomerID</param>
		/// <returns>结果</returns>
		public bool HasCustomers(string customerID)
		{
			return CustomersDao.HasCustomers(customerID);
		}

		/// <summary>
		/// 插入Customers
		/// </summary>
		/// <param name="customersQp">Customers</param>
		/// <returns>结果</returns>
		public int InsertCustomers(CustomersQP customersQp)
		{
			return CustomersDao.InsertCustomers(customersQp);
		}

		///<summary>
		///删除Customers
		///</summary>
		///<param name="customerID">CustomerID</param>
		///<returns>结果</returns>
		public bool RemoveCustomers(string customerID)
		{
			return CustomersDao.RemoveCustomers(customerID);
		}
	
		/// <summary>
		/// 更新Customers
		/// </summary>
		/// <param name="customersQp">Customers</param>
		/// <returns>结果</returns>
		public bool UpdateCustomers(CustomersQP customersQp)
		{
			return CustomersDao.UpdateCustomers(customersQp);
		}

		/// <summary>
		/// 批量删除Customers集合
		/// </summary>
		/// <param name="customerIDs">CustomerID集合</param>
		/// <returns>结果</returns>
		public bool RemoveCustomerss(IList<string> customerIDs)
		{
			bool result = true;
            using (IDalSession session = CustomersDao.Writer.BeginTransaction())
            {
                foreach (string customerID in customerIDs)
                {
                    result = CustomersDao.RemoveCustomers(customerID);
                }
                session.Complete();
            }
            return result;
		}

		#endregion
	}
}

